function pattern = asce_pattern(d)
% this function may be execute only once in whole comput session.
% the purpose is to get a large pattern matrix for later use.
% the from is from degree d to degree (d+1),the pattern is until d
% the result is stored in three columns .
m_rows = (d+2)*(d+3)/2;
m_cols = (d+1)*(d+2)/2;
pattern = spalloc(m_rows,m_cols,2*m_rows);
idx_col = [1];
for d_row = 1:d+1
    % each cell for a degree, get the row index,the column index used the
    % row index last time;
    idx_row = (idx_col(end)+1:idx_col(end)+d_row+1);
    % put the values of j and k to corresponding entrys
    for j = 1:d_row
        pattern(idx_row(j),idx_col(j)) = d_row - j + 1;
        pattern(idx_row(j)+1,idx_col(j)) = j;
    end
    idx_col = idx_row;
end